<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="easyui/1.3.4/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="css/wu.css" />
<link rel="stylesheet" type="text/css" href="css/icon.css" />
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="easyui/1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="easyui/1.3.4/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript">
</script>

</head>

<body>
	<div class="easyui-layout" data-options="fit:true">
    <!-- <div data-options="region:'west',border:true,split:true," title="分类管理" style="width:150px; padding:5px;">
        <ul id="wu-category-tree" class="easyui-tree"></ul>
    </div> -->
    <div data-options="region:'center',border:false">
    	<!-- Begin of toolbar -->
        <div id="wu-toolbar">
            <div class="wu-toolbar-button">
               <!-- <a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="openAdd()" plain="true">添加学生</a>  -->
               <!-- <a href="#" class="easyui-linkbutton" iconCls="icon-edit" onclick="updateStudentInterview()" plain="true">修改</a> -->
               <c:if test="${activeUser.tid != -1 }">
                <a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="openEdit()" plain="true">修改</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="addStudentInterview()" plain="true">添加学生面试信息</a>
               </c:if> 
                <!-- <a href="#" class="easyui-linkbutton" iconCls="icon-reload" onclick="reload()" plain="true">刷新</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-print" onclick="openAdd()" plain="true">打印</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-help" onclick="openEdit()" plain="true">帮助</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-undo" onclick="remove()" plain="true">撤销</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-redo" onclick="cancel()" plain="true">重做</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-sum" onclick="reload()" plain="true">总计</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-back" onclick="reload()" plain="true">返回</a>
                <a href="#" class="easyui-linkbutton" iconCls="icon-tip" onclick="reload()" plain="true">提示</a>
                <a href="#" class ="easyui-linkbutton" iconCls="icon-save" onclick="reload()" plain="true">保存</a>-->
                <a href="#" class="easyui-linkbutton" iconCls="icon-cut" onclick="getChart()" plain="true">生成报表</a>
            </div>
            <div class="wu-toolbar-search">
                <label>起始时间：</label><input name="start"  class="easyui-datebox" style="width:100px">
             
                <label>结束时间：</label><input name="end" class="easyui-datebox" style="width:100px">
                <label>选择班级：</label> 
                <select class="easyui-combobox" name="zu" panelHeight="auto" style="width:100px">
                    <option value="0">--请选择--</option>
                    <c:forEach items="${classList }" var="c">
                    	<option style="color: black" value="${c.cid }">${c.cname }</option>
                   	</c:forEach>
                </select>
                <label>学生姓名：</label><input name="name" class="wu-text" style="width:100px">
                <c:if test="${activeUser.tid == -1 }">
                	<label>项目经理：</label>
                	<select class="easyui-combobox" name="tname" panelHeight="auto" style="width:100px">
                    <option value="">--请选择--</option>
                    <c:forEach items="${teacherList }" var="t">
                    	<option style="color: black" value="${t.username }">${t.username }</option>
                   	</c:forEach>
                </select>
                	<!-- <input name="tname" class="wu-text" style="width:100px"> -->
               	</c:if>
                <!-- 超链接不好使，只能用button按钮 -->
                <button onclick="searchName()" class="easyui-linkbutton" iconCls="icon-search">开始检索</button>
            </div>
        </div>
        <!-- End of toolbar -->
        <table id="wu-datagrid" toolbar="#wu-toolbar"></table>
    </div>
</div>
<!-- Begin of easyui-dialog -->
<div id="wu-dialog" class="easyui-dialog" data-options="closed:true,iconCls:'icon-save'" style="width:400px; padding:10px;">
	<form id="wu-form" method="post">
		<input type="hidden" name="sid" class="wu-text" />
        <table>
        	
            <tr>
                <td width="120" align="right">学生姓名:</td>
                <td><input type="text" name="sname" class="wu-text" /></td>
            </tr>
            <tr>
                <td width="120" valign="top" align="right">面试公司:</td>
                <td><input name="company" class="wu-text" /></td>
            </tr>
            <tr>
                <td width="120" valign="top" align="right">上午:</td>
                <td><input name="" class="wu-text" /></td>
            </tr>
            <tr>
                <td width="120" valign="top" align="right">下午:</td>
                <td><input name="" class="wu-text" /></td>
            </tr>
            <tr>
                <td width="120" valign="top" align="right">面试前辅导录音是否提交:</td>
                <td>
                	<select class="easyui-combobox" name="firstguideflag" panelHeight="auto" >
	                	<option value="1">是</option>
	                	<option value="0">否</option>
                	</select>
                </td>
            </tr>
            <tr>
                <td width="120" valign="top" align="right" >面试后诊断录音是否提交:</td>
                <td>
                	<select class="easyui-combobox" name="laterguideflag" panelHeight="auto" >
	                	<option value="1">是</option>
	                	<option value="0">否</option>
                	</select>
                </td>
            </tr>
        </table>
    </form>
	<form id="wu-form">
		<table>
			<tr align="center">
			<td>学生姓名:</td>
			<td><input class="easyui-validatebox" type="text" name="sname"></td>
			</tr>
			<tr align="center">
			<td>班级:</td>
			<td>
				<select style="width: 140px;" name="cid" id="cid">
	    		</select>
			</td>
			</tr>
			<tr align="center">
			<td>就业状态:</td>
			<td>
				<select name="job_status" >
					<option value="1">就业</option>
					<option value="2">未就业</option>
				</select>
			</td>
			</tr>
			<tr align="center">
			<td>联系状态:</td>
			<td>
				<select name="call_status">
					<option value="1">正常</option>
					<option value="2">失联</option>
				</select>
			</td>
			</tr>
			
		</table>
	</form>
</div>
<div id="addInterview-dialog" class="easyui-dialog" data-options="closed:true,iconCls:'icon-save'" style="width:400px; padding:10px;">
	<form id="add-form" method="post">
		<input type="hidden" name="iid" class="wu-text" />
        <table>
        	<tr>
        		<td width="80" align="right">学生姓名：</td>
        		<td>
        			<select id="studentData" name="sid" panelHeight="auto" >
	                	
                	</select>
                </td>
          
             
            <tr>
                <td width="120" valign="top" align="right">面试公司:</td>
                <td><input name="company" class="wu-text" data-options="required:true"/></td>
            </tr>
            <tr>
				<td width="80" valign="top" align="right">面试时间：</td>
				<td>
					<input type="text" name="mstime" class="easyui-timespinner" data-options="min:'8:30',max:'19:00',required:true"/>
				</td>
			</tr>
            <tr>
                <td width="120" valign="top" align="right">面试前辅导录音是否提交:</td>
                <td>
                	<select class="easyui-combobox" name="firstguideflag" panelHeight="auto" >
	                	<option value="1">是</option>
	                	<option value="0">否</option>
                	</select>
                </td>
            </tr>
            <tr>
                <td width="120" valign="top" align="right" >面试后诊断录音是否提交:</td>
                <td>
                	<select class="easyui-combobox" name="laterguideflag" panelHeight="auto" >
	                	<option value="1">是</option>
	                	<option value="0">否</option>
                	</select>
                </td>
            </tr> 
           
        </table>
    </form>
</div>
<script type="text/javascript">


function updateStudentInterview(){
	var item = $('#wu-datagrid').datagrid('getSelected');
	var sid = item.sid;
	var iid = item.iid;
	if(item){
		$.post(
				"<%=request.getContextPath()%>/ylq/toAddInterview",
				{
					iid:iid,
					sid:sid
				},
				function (data){
					alert(data);
				},
				"json"
			);		
		$('#addInterview-dialog').dialog({
			
				
			closed: false,
			modal:true,
	        title: "修改学生面试信息",
	        buttons: [{
	            text: '确定',
	            iconCls: 'icon-ok',
	            handler: addInterview
	        }, {
	            text: '取消',
	            iconCls: 'icon-cancel',
	            handler: function () {
	                $('#addInterview-dialog').dialog('close');                    
	            }
	        }]
	    });
		
	}else{
		$.messager.alert('信息提示','请选择要修改的数据','info');
	}
}


	$(function (){
		$('#studentData').combotree({    
		    url: '<%=request.getContextPath()%>/data/getStudents',    
		    required: true,
		    width:200
		}); 
		

	})
/**
* Name 载入菜单树
*/
/* $('#wu-category-tree').tree({
	url:'temp/menu.php',
	onClick:function(node){
		alert(node.text);
	}
});

/**
 * 检索
 */
 function searchName(){
	var sname = $("[name='name']").val();
	var cid = $("[name='zu']").val();
	var start = $("[name='start']").val();
	var end = $("[name='end']").val();
	var tname = $("[name='tname']").val();
	$("#wu-datagrid").datagrid('load',{
		sname:sname,
		cid:cid,
		start:start,
		end:end,
		tname:tname
	});
}
function addStudentInterview(){
	$('#add-form').form('clear');
	$('#addInterview-dialog').dialog({
		closed: false,
		modal:true,
        title: "添加学生面试信息",
        buttons: [{
            text: '确定',
            iconCls: 'icon-ok',
            handler: add
        }, {
            text: '取消',
            iconCls: 'icon-cancel',
            handler: function () {
                $('#addInterview-dialog').dialog('close');                    
            }
        }]
    });
}
/**
* Name 添加记录
*/
function add(){
	$('#add-form').form('submit', {
		url:'<%=request.getContextPath() %>/data/addInterview',
		success:function(data){
			if(data){
				$.messager.alert('信息提示','提交成功！','info');
				$('#addInterview-dialog').dialog('close');
				$('#wu-datagrid').datagrid("reload");
			}
			else
			{
				$.messager.alert('信息提示','提交失败！','info');
			}
		}
	});
}
function getChart(){
	location.href="<%=request.getContextPath()%>/data/getTable";
}
/**
* Name 修改记录
*/
function edit(){
	$('#wu-form').form('submit', {
		url:'data/getInfoBySid',
		success:function(data){
			if(data){
				$.messager.alert('信息提示','提交成功！','info');
				$('#wu-dialog').dialog('close');
			}
			else
			{
				$.messager.alert('信息提示','提交失败！','error');
			}
		}
	});
}

/**
* Name 删除记录
*/
function remove(){
	$.messager.confirm('信息提示','确定要删除该记录？', function(result){
		if(result){
			var items = $('#wu-datagrid').datagrid('getSelections');
			var ids = [];
			$(items).each(function(){
				ids.push(this.productid);	
			});
			//alert(ids);return;
			$.ajax({
				url:'',
				data:'',
				success:function(data){
					if(data){
						$.messager.alert('信息提示','删除成功！','info');		
					}
					else
					{
						$.messager.alert('信息提示','删除失败！','info');		
					}
				}	
			});
		}	
	});
}

/**
* Name 打开添加窗口
*/
function openAdd(){
	$.ajax({
		type:"post",
		url:"/addController/listByClasses",
		dataType:"json",
		data:{},
		success:function(classes){
			$("#cid").empty();
			for(var a in classes){
				$("#cid").append("<option value='"+classes[a].id+"'>"+classes[a].name+"</option>")
			}
		}
		
	})
	
	$('#wu-form').form('clear');
	$('#wu-dialog').dialog({
		closed: false,
		modal:true,
        title: "添加信息",
        buttons: [{
            text: '确定',
            iconCls: 'icon-ok',
            handler: add
        }, {
            text: '取消',
            iconCls: 'icon-cancel',
            handler: function () {
                $('#wu-dialog').dialog('close');                    
            }
        }]
    });
}

/**
* Name 打开修改窗口
*/
function openEdit(){
	/* $('#wu-form').form('clear'); */
	var item = $('#wu-datagrid').datagrid('getSelected');
	if(item){
		$('#add-form').form('load', item);
	}
	//alert(item.productid);return;
	/*  $.ajax({
		url:'',
		data:'',
		success:function(data){
			if(data){
				$('#wu-dialog').dialog('close');	
			}
			else{
				//绑定值
				$('#wu-form').form('load', data)
			}
		}	
	});  */
	$('#addInterview-dialog').dialog({
		closed: false,
		modal:true,
        title: "修改信息",
        buttons: [{
            text: '确定',
            iconCls: 'icon-ok',
            handler: add
        }, {
            text: '取消',
            iconCls: 'icon-cancel',
            handler: function () {
                $('#addInterview-dialog').dialog('close');                    
            }
        }]
    });
}	

/**
* Name 分页过滤器
*/
function pagerFilter(data){            
	if (typeof data.length == 'number' && typeof data.splice == 'function'){// is array                
		data = {                   
			total: data.length,                   
			rows: data               
		}            
	}        
	var dg = $(this);         
	var opts = dg.datagrid('options');          
	var pager = dg.datagrid('getPager');          
	pager.pagination({                
		onSelectPage:function(pageNum, pageSize){                 
			opts.pageNumber = pageNum;                   
			opts.pageSize = pageSize;                
			pager.pagination('refresh',{pageNumber:pageNum,pageSize:pageSize});                  
			dg.datagrid('loadData',data);                
		}          
	});           
	if (!data.originalRows){               
		data.originalRows = (data.rows);       
	}         
	var start = (opts.pageNumber-1)*parseInt(opts.pageSize);          
	var end = start + parseInt(opts.pageSize);        
	data.rows = (data.originalRows.slice(start, end));         
	return data;       
} 
	function format(value, row, index){
		if(row == 1){
			return "是";
		}if(row == 0){
			return "否";
		}
	}
	/**
	* Name 载入数据
	*/
	$('#wu-datagrid').datagrid({
		url:'<%=request.getContextPath()%>/data/shouyeData',
		loadFilter:pagerFilter,		
		rownumbers:true,
		singleSelect:true,
		pageSize:15,           
		pagination:true,
		multiSort:true,
		fitColumns:true,
		loadMsg:'正在加载数据，请稍后...',
		fit:true,
		columns:[[
			{ checkbox:true},
			{ field:'iid',title:'面试ID',width:100,sortable:true},
			{ field:'sid',title:'学生ID',width:100,sortable:true},
			{ field:'cname',title:'班级',width:100,sortable:true},
			{ field:'presentdate',title:'日期',width:100,sortable:true, formatter:function(data){
				var date = new Date(data);
				var Y = date.getFullYear()+'-';
				var M = date.getMonth()+'-';
				var D = date.getDate();
				return Y+M+D;
			}},
			{ field:'username',title:'项目经理',width:90,sortable:true},
			{ field:'sname',title:'姓名',width:90},
			{ field:'company',title:'面试公司',width:90},
			{ field:'mstime1',title:'上午',width:90},
			{ field:'mstime2',title:'下午',width:90},
			{ field:'firstguideflag',title:'面试前辅导录音是否提交',width:140, formatter:function(data){
				if(data == 1){
					return "是";
				}if(data == 0){
					return "否";
				}
				
			}},
			{ field:'laterguideflag',title:'面试后诊断录音是否提交',width:140, formatter:function(data){
				if(data == 1){
					return "是";
				}if(data == 0){
					return "否";
				}
				
			}}
			
		]]
	});
	
</script>
</body>

</html>